package com.santu.edu.supporter.biz.order.pojo.enums;

import com.santu.edu.supporter.exception.BizException;
import com.santu.edu.supporter.exception.CustomError;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
@AllArgsConstructor
@Getter
public enum OrderStatusEnum {
    /**
     *
     */
    TO_BE_PAID(0, "待支付"),
    TO_BE_SHIPPED(1, "待发货"),
    SHIPPED(2, "已发货"),
    COMPLETED(3, "已完成"),
    TO_BE_REFUND(4,"待退款"),
    REFUNDED(5,"已退款"),
    REFUNDED_FAIL(6,"退款失败"),

    ;

    private final Integer code;

    private final String desc;
    public static OrderStatusEnum convert(Integer code) {
        for (OrderStatusEnum e : OrderStatusEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        throw BizException.causeBy(CustomError.ENUM_CONVERT_ERROR,"TimeSectionType转换异常");
    }
}
